import torch, torchvision
from torch import nn
from torch.nn import L1Loss
import torch.nn.functional as F

# 模型的保存

vgg16 = torchvision.models.vgg16(pretrained=True)

# 方式一：
torch.save(vgg16, 'vgg16_model.pth')

# 方式二：
torch.save(vgg16.state_dict(), 'vgg16_model_method2.pth')